package net.bblot.lottery.util;

import android.content.Context;
import android.os.Build;
import android.text.TextUtils;

import net.bblot.lottery.activity.QApplication;

/**
 * Created by feng on 2017/9/15.
 */

public class TextUtil {

    public static boolean copyTextToClipboard(String text) {
        if (TextUtils.isEmpty(text)) {
            return false;
        }
        if (Build.VERSION.SDK_INT >= 11) {
            android.content.ClipboardManager clipboardManager = (android.content.ClipboardManager) QApplication.context.getSystemService(Context.CLIPBOARD_SERVICE);
            if (clipboardManager == null) {
                return false;
            }
            clipboardManager.setText(text);
        } else {
            android.text.ClipboardManager clipboardManager = (android.text.ClipboardManager) QApplication.context.getSystemService(Context.CLIPBOARD_SERVICE);
            if (clipboardManager == null) {
                return false;
            }
            clipboardManager.setText(text);
        }
        return true;
    }

}
